package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-18
 * Time: 8:15
 */
public class AddOperation implements IOperation{

    @Override
    public void work(Booklist booklist) {
        System.out.println("新增图书！");
        System.out.println("请输入书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        System.out.println("请输入作者名：");
        String author = scan.nextLine();
        System.out.println("请输入价格：");
        int price = scan.nextInt();
        scan.nextLine();
        System.out.println("请输入类型：");
        String type = scan.nextLine();

        int pos = booklist.getUseSize();
        Book book = new Book(name,author,type,price);
        booklist.setBooks(pos,book);
        System.out.println("添加成功");
        booklist.setUseSize(pos+1);
    }
}
